<?php

class File {
	
	var $mFileName = "";
	var $mBaseDir = "";
	var $mExtension = "";
	var $mBasename = "";
	
	function __construct($fileName) {
		$this->mFileName = $fileName;
		$path_parts = pathinfo($this->mFileName);
		if (isset($path_parts["dirname"])) {
			$this->mBaseDir = $path_parts["dirname"];
		}
		if (isset($path_parts["basename"])) {
			$this->mBasename = $path_parts["basename"];
		}
		if (isset($path_parts["extension"])) {
			$this->mExtension = $path_parts["extension"];
		}
	}
	
	function getName() {
		return $this->mFileName;
	}
	
	function getBaseName() {
		return $this->mBasename;
	}
	
	function getExtension() {
		return $this->mExtension;
	}
	
	function getBaseDir() {
		return $this->mBaseDir;
	}
	
	function getMimeType() {
		switch ($this->mExtension) {
			case "jpg":
			case "jpeg":
				return "image/jpeg";
				break;
		}
	}
	
	function getContent() {
		if (file_exists($this->mFileName)) {
			return implode("", file($this->mFileName));
		}
	}
	
	function isExists() {
		return file_exists($this->mFileName);
	}
	
	function getSize() {
		return filesize($this->mFileName);
	}
	
	function getCreateDate() {
		return filectime($this->mFileName);
	}
	
	static function remove($file) {
		if (file_exists($file->mFileName))
			return @unlink($file->mFileName);
		return false;
	}
	
}

?>